import request from '@/utils/request'

export function QueryProductList(params) {
  return request({
    url: '/api/Product/QueryProductList',
    method: 'POST',
    params
  })
}

//获取商品分类
export function GetProductType(params) {
  return request({
    url: '/api/Product/QueryProductTypeInfo',
    method:"post",
    params
  })
}

// 图片上传接口

export function ProductUploadFile({ShopId,ProductId},file){

  // 创建一个formdata ，修改axios的post请求的header 
  let form = new FormData();
  form.append("file",file);
  const config = {
    headers: { "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryn8D9asOnAnEU4Js0" },
  }
  return request.post(`/api/Product/ProductUploadFile?ShopId=${ShopId}&ProductId=${ProductId}`,form,config)

}

//添加商品
export function CreateProduct(data){
  return request({
    url: '/api/Product/CreateProduct',
    method:"post",
    data
  })
}

//删除商品

export function DeleteProduct(params){
  return request({
    url: '/api/Product/DeleteProduct',
    params
  })
}

//查询商品详情
export function GetProductInfo(params){
  return request({
    url: '/api/Product/GetProductInfo',
    params
  })
}

//更新商品
export function UpdateProduct(data){
  return request({
    url: '/api/Product/UpdateProduct',
    method:"post",
    data
  })
}



